package com.example.demo.test;

import com.alibaba.excel.EasyExcel;
import com.example.demo.domain.Person;
import com.example.demo.domain.ProductFeaturesEnum;
import com.example.demo.listener.ExcelPersonDataListener;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.Map;

@Component
public class test03
{

    public static void main(String[] args) {
        //一个文件有好几个sheet，通过sheetName分别读取
        EasyExcel
                .read("F:\\210615_140237.xlsx", Person.class, new ExcelPersonDataListener())
                .sheet("日了狗")
                .doRead();
        EasyExcel
                .read("F:\\210615_140237.xlsx", Person.class, new ExcelPersonDataListener())
                .sheet("你大爷")
                .doRead();

        String productProperty = "non_liquid_cosmetics,with_magnetic,liquid,powder";
//        String productProperty = "non_liquid_cosmetics,with_magnetic,liquid,powder,special_sensitive_goods";
        boolean hasBattery = false;
        // 只要选了纯电或者内电，都为带电
        if (StringUtils.contains(
                productProperty, ProductFeaturesEnum.WITH_ELECTRICITY.getValue())
                || StringUtils.contains(
                productProperty, ProductFeaturesEnum.WITH_PURE_ELECTRICITY.getValue())) {
            hasBattery = true;
        }

        boolean isSpecialGoods =
                StringUtils.contains(
                        productProperty, ProductFeaturesEnum.SPECIAL_SENSITIVE_GOODS.getValue());
        //货物敏感类型的值
        int productItemSensitivityType = 0;
        if(isSpecialGoods){
            productItemSensitivityType = 2;
        }else if(!isSpecialGoods && hasBattery) {
            productItemSensitivityType = 1;
        }else {
            productItemSensitivityType = 0;
        }

        // wishpost的特殊要求，特货必须带电
        if (isSpecialGoods) {
            hasBattery = true;
        }

        System.out.println("hasBattery："+hasBattery);
        System.out.println("productItemSensitivityType："+productItemSensitivityType);




        // 是否包含非液体化妆品
//        boolean isAneroidMarkup =
//                StringUtils.contains(
//                        productProperty, ProductFeaturesEnum.NON_LIQUID_COSMETICS.getValue());
        // 是否含纯电池产品
//        boolean isOnlyBattery =
//                StringUtils.contains(
//                        productProperty, ProductFeaturesEnum.WITH_PURE_ELECTRICITY.getValue());
//        System.out.println("isAneroidMarkup = " + isAneroidMarkup);
//        System.out.println("isOnlyBattery = " + isOnlyBattery);


        Map<String, Object> item = new LinkedHashMap<>();
        String code = "PK0064";
        // 如果是三通下的渠道：香港DHL5000大小货，country_of_origin为HK
        if (code.equals("PK0064")) {
            item.put("country_of_origin", "HK");
        }



    }


}
